blob: 84383aa9e4ab769219ba79e3ae7fecff8630978d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
---
import Comment from '../../components/Comment.astro';
import For from '../../components/For.astro';
import Show from '../../components/Show.astro';
import Layout from '../../layouts/Layout.astro';
import fetchAPI from '../../lib/api';
import type { IComment, IStory } from '../../types.js';
const { id } = Astro.params as { id: string };
const story = (await fetchAPI(`item/${id}`)) as IStory;
---
<Layout>
<div>
<header>
<a href={story.url} target="_blank">
<h1>{story.title}</h1>
</a>
<Show when={story.domain}>
<span class="host">({story.domain})</span>
</Show>
<p class="meta">
{story.points} points | by
<a href={`/users/${story.user}`}>
{story.user}
</a>
{story.time_ago}
</p>
</header>
<main>
<p>
{story.comments_count ? story.comments_count + ' comments' : 'No comments yet.'}
</p>
<ul class="comment-children">
<For each={story.comments}>
{(comment: IComment) => <Comment comment={comment} />}
</For>
</ul>
</main>
</div>
</Layout>
<style>
header {
background-color: rgb(248 250 252);
padding: 1.8em 2em 1em;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
h1 {
display: inline;
font-size: 1.5em;
margin: 0;
margin-right: 0.5em;
}
.host,
.meta,
.host a {
color: rgb(51 65 85);
}
.meta a {
text-decoration: underline;
}
main {
background-color: rgb(248 250 252);
margin-top: 10px;
padding: 0 2em 0.5em;
}
main p {
margin: 0;
font-size: 1.1em;
padding: 1em 0;
position: relative;
}
main :global(ul) {
list-style-type: none;
padding: 0;
margin: 0;
}
@media (max-width: 600px) {
h1 {
font-size: 1.25em;
}
}
ul :global(ul) {
margin-left: 1.5em;
}
</style>
|